//
//  DataStatisticsVC.m
//  NtoccShipper
//
//  Created by mac on 2019/11/9.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "DataStatisticsVC.h"
#import "SendGoodsDatasVC.h"
#import "FreightStatisticsVC.h"
//#import "InvoiceStatisticsVC.h"
#import "InvoiceStatisticsVC.h"

@interface DataStatisticsVC ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) CJTableView *tableView;
@property (nonatomic,copy)NSArray *arrImgs;
@property (nonatomic,copy)NSArray *arrTitles;
@end

@implementation DataStatisticsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitleName:CJLString(@"数据统计")];
    [self setBackLeftButton:@""];
    [self.view addSubview:self.tableView];
}

#pragma mark----tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    //return self.titles.count+ 1;
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrTitles.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *MeViewCellId = @"cellId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MeViewCellId];
    if (cell ==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MeViewCellId];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell.textLabel.font = [UIFont cjTitleFont15];
        cell.textLabel.textColor = [UIColor cjMainTextColor];
    }
    
    cell.imageView.image = [UIImage imageNamed:self.arrImgs[indexPath.row]];
    CGSize itemSize = CGSizeMake(17, 17);
    UIGraphicsBeginImageContextWithOptions(itemSize, NO, UIScreen.mainScreen.scale);
    CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    cell.textLabel.text = self.arrTitles[indexPath.row];
    cell.separatorInset = UIEdgeInsetsMake(0.3f, 50.0f, 0.0f,0.0f);
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row == 0) {
        SendGoodsDatasVC *vc = [[SendGoodsDatasVC alloc]init];
        vc.isSendGoods = YES;
        [self pushVc:vc];
    }else if (indexPath.row == 1){
        SendGoodsDatasVC *vc = [[SendGoodsDatasVC alloc]init];
        vc.isSendGoods = NO;
        [self pushVc:vc];
    }else if (indexPath.row == 2){
        FreightStatisticsVC *vc = [[FreightStatisticsVC alloc]init];
        [self pushVc:vc];

    }else if(indexPath.row == 3){
        InvoiceStatisticsVC *vc = [InvoiceStatisticsVC new];
        [self pushVc:vc];
    }
}

- (NSArray *)arrTitles{
    
    if(!_arrTitles){
        _arrTitles = @[@"发货统计",@"收货统计",@"运费统计",@"发票统计"];
    }
    return _arrTitles;
}

- (NSArray *)arrImgs{
    if(!_arrImgs){
        _arrImgs = @[@"zcj_icon_tongji_fahuo",@"zcj_icon_tongji_shouhuo",@"zcj_icon_tongji_yunfei",@"zcj_icon_yundan"];
    }
    return _arrImgs;
}

- (CJTableView *)tableView{
    if (!_tableView) {
        _tableView = CJTableView.tbInitFrameStyle(CGRectMake(0,kTopHeight + CJTableToTopHeight + CJToViewMarginH, SCREEN_WIDTH, SCREEN_HEIGHT-kTopHeight - CJTableToTopHeight - CJToViewMarginH),UITableViewStylePlain)
        .tbDelegate(self)
        .tbDataSource(self)
        .tbSetOther(YES)
        .tbEstimatedRowHeight(YES)
//        .tbMjHeadFooter(YES)
        ;
//        WS(ws);
//        _footerView = [[MineFooterView alloc] init];
//        _footerView.height = LW(100);
//        _tableView.tableFooterView= _footerView;

    }
    
    return _tableView;
}

@end
